/**
 * H5.js Class
 * 2012. 4. 12.
 * Kim Chan Soo
 * Desc : HTML5 Game Engine
 */

/**
 * The H5 global namespace object. If H5 is already defined, the
 * existing H5 object will not be overwritten so the defined
 * namespace are preserved.
 * 
 * @class H5
 * @static
 */
if(typeof H5 === "undefined") var H5 = {};//or shorter : var H5 = H5 || {};

/**
 * Returns the namespace specified and creates it if it doesn't exist
 * <pre>
 * H5.namespace("H5.property.package");
 * H5.namespace("property.package");
 * </pre>
 * Be careful when naming packages. Reserved words may work in some browsers
 * and not others. For instance, the following will fail in Safari:
 * <pre>
 * H5.namespace("H5.long.net");
 * </pre>
 * This fails because "long" is a future reserved word in ECMAScript.
 *  
 * @method namespace
 * @static
 * @param {String} A namespace to create.
 * @return {Object} A reference to the last namespace object created.
 */
H5.namespace = function(name)
{
	if(typeof name == "undefined") throw new Error("Namespace is undefined.");
	
	var parts = name.split("."), current = H5;
	for(var i = (parts[0] == "H5") ? 1 : 0 ; i < parts.length ; i++)
	{
		if(!current[parts[i]]) current[parts[i]] = {};
		current = current[parts[i]];
	}
	return current;
};
H5.Event =
{
	addEventListener: function(target, type, func)
	{
		if(typeof target.addEventListener === "function")
		{
			H5.Event.addEventListener = function(target, type, func)
			{
				target.addEventListener(type, func, false);
			};
		}
		else if(typeof target.attachEvent === "function")
		{
			H5.Event.addEventListener = function(target, type, func)
			{
				target.attachEvent("on" + type, func);
			};
		}
		else
		{
			H5.Event.addEventListener = function(target, type, func)
			{
				target["on" + type] = func;
			};
		}
		//H5.Event.addEventListener(target, type, func);
	}
};
H5.onLoad = function()
{
};
console.log("test");

/* The self-executable pattern
var MYAPP = {};
MYAPP.dom = function(){
// initialization code...
function _private(){
// ... body
}
return {
getStyle: function(el, prop) {
console.log('getStyle');
_private();
},
setStyle: function(el, prop, value) {
console.log('setStyle');
}
};
}();
*/